﻿<src:OverlayWindow x:Class="GW2PAO.Views.TradingPost.TPCalculatorView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:src="clr-namespace:GW2PAO.Views"
        xmlns:vm="clr-namespace:GW2PAO.ViewModels.TradingPost"
        xmlns:converters="clr-namespace:GW2PAO.Style.Converters"
        xmlns:core="clr-namespace:GW2PAO.PresentationCore;assembly=GW2PAO.PresentationCore"
        Width="215" SizeToContent="Height"
        WindowStyle="None" AllowsTransparency="true" Background="Transparent"
        ResizeMode="NoResize"
        Topmost="True"
        Closed="Window_Closed"
        TextOptions.TextFormattingMode="Display">
    
    <src:OverlayWindow.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../Style/ResourceLibrary.xaml" />
            </ResourceDictionary.MergedDictionaries>
            
            <BooleanToVisibilityConverter x:Key="BoolToVisibility" />
            <SolidColorBrush x:Key="TextBoxBorder" Color="Orange" Opacity="0.5" />
            
        </ResourceDictionary>
    </src:OverlayWindow.Resources>
    
    <src:OverlayWindow.DataContext>
        <vm:TPCalculatorViewModel />
    </src:OverlayWindow.DataContext>

    <Grid>

        <Grid.Effect>
            <DropShadowEffect Color="Black" BlurRadius="10" Opacity="0.5" Direction="0" ShadowDepth="0" />
        </Grid.Effect>

        <Grid.Background>
            <RadialGradientBrush Opacity="0.5" Center="0,0" GradientOrigin="0,0" RadiusX="1" RadiusY="1">
                <GradientStop Color="#FF5B4411" Offset="0"/>
                <GradientStop Color="#005B4411" Offset="1"/>
            </RadialGradientBrush>
        </Grid.Background>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Border Name="TitleBar" Style="{StaticResource TitleBarStyle}"
                MouseLeftButtonDown="TitleBar_MouseLeftButtonDown"
                Grid.Row="0" BorderThickness="0,1,0,1">
            <Grid Margin="5,0,0,0">

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="30" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="35" />
                    <ColumnDefinition Width="35" />
                </Grid.ColumnDefinitions>

                <Image Name="TitleImage" Grid.Column="0"
                       VerticalAlignment="Center"
                       Height="30" Width="30"
                       Source="/Resources/merchant.png"
                       MouseDown="TitleImage_MouseDown">
                    <Image.ContextMenu>
                        <ContextMenu>
                            <MenuItem Header="Reset" Command="{Binding ResetCommand}" />
                            <Separator />
                            <MenuItem Header="Close" Click="CloseWindowButton_Click" />
                        </ContextMenu>
                    </Image.ContextMenu>
                    <Image.Style>
                        <Style TargetType="{x:Type Image}">
                            <Setter Property="Effect">
                                <Setter.Value>
                                    <DropShadowEffect ShadowDepth="0"
                                              Color="Goldenrod"
                                              Opacity="0"
                                              BlurRadius="25"/>
                                </Setter.Value>
                            </Setter>
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Trigger.EnterActions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation To="1"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:00.1"/>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.EnterActions>
                                    <Trigger.ExitActions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation To="0"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:0.1"/>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.ExitActions>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </Image.Style>
                </Image>

                <core:OutlinedTextBlock Grid.Column="1" Margin="5,0,0,0"
                                        VerticalAlignment="Center"
                                        Fill="Orange" FontFamily="Candara" FontSize="17"
                                        Text="TP Calculator" />

                <Button Name="CollapseExpandButton"
                    Grid.Column="2"
                    Margin="5"
                    Click="CollapseExpandButton_Click">
                    <Button.Style>
                        <Style TargetType="Button" BasedOn="{StaticResource TitleBarButtonStyle}">
                            <Setter Property="Content" Value="{StaticResource CollapseGraphic}" />
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Visibility, ElementName=Calculator}" Value="Collapsed">
                                    <DataTrigger.Setters>
                                        <Setter Property="Content" Value="{StaticResource ExpandGraphic}" />
                                    </DataTrigger.Setters>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Button.Style>
                </Button>

                <Button Name="CloseWindowButton"
                    Grid.Column="3"
                    Margin="5"
                    Style="{StaticResource TitleBarButtonStyle}"
                    Content="{StaticResource CloseGraphic}"
                    Click="CloseWindowButton_Click" />
            </Grid>
        </Border>

        <Grid Name="Calculator" Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            
            <!--Buy Price-->
            <StackPanel Grid.Row="0"
                        Orientation="Vertical"
                        Margin="5">
                <core:OutlinedTextBlock Text="Buy Price" FontSize="14" ToolTipService.ShowDuration="30000">
                    <core:OutlinedTextBlock.ToolTip>
                        <ToolTip>
                            <StackPanel Orientation="Horizontal">
                                <core:OutlinedTextBlock Text="Break Even At:" FontSize="12"/>
                                <StackPanel Orientation="Horizontal" Margin="5,0,0,0" VerticalAlignment="Bottom">
                                    <core:OutlinedTextBlock Text="{Binding BreakEvenBuyPrice.Gold}" />
                                    <Image Source="../../Resources/gold_coin.png"
                                           Height="11" Width="11"
                                           Margin="1,0,5,0"/>
                                    <core:OutlinedTextBlock Text="{Binding BreakEvenBuyPrice.Silver}"/>
                                    <Image Source="../../Resources/silver_coin.png"
                                           Height="11" Width="11"
                                           Margin="1,0,5,0"/>
                                    <core:OutlinedTextBlock Text="{Binding BreakEvenBuyPrice.Copper}"/>
                                    <Image Source="../../Resources/copper_coin.png"
                                           Height="11" Width="11"
                                           Margin="1,0,0,0"/>
                                </StackPanel>
                            </StackPanel>
                        </ToolTip>
                    </core:OutlinedTextBlock.ToolTip>
                    <core:OutlinedTextBlock.Style>
                        <Style TargetType="{x:Type core:OutlinedTextBlock}" BasedOn="{StaticResource {x:Type core:OutlinedTextBlock}}">
                            <Setter Property="Effect">
                                <Setter.Value>
                                    <DropShadowEffect ShadowDepth="0"
                                                  Color="Gold"
                                                  Opacity="0"
                                                  BlurRadius="15"/>
                                </Setter.Value>
                            </Setter>
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Trigger.EnterActions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation To="0.25"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:00.1"/>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.EnterActions>
                                    <Trigger.ExitActions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation To="0"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:0.1"/>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.ExitActions>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </core:OutlinedTextBlock.Style>
                </core:OutlinedTextBlock>
                <StackPanel Orientation="Horizontal" Margin="0,5,0,0">
                    <TextBox Width="50" BorderBrush="{StaticResource TextBoxBorder}"
                             FlowDirection="RightToLeft" GotKeyboardFocus="TextBox_GotKeyboardFocus" GotMouseCapture="TextBox_GotMouseCapture">
                        <TextBox.Text>
                            <Binding Path="BuyPrice.Gold" UpdateSourceTrigger="PropertyChanged" />
                        </TextBox.Text>
                    </TextBox>
                    <Image Source="../../Resources/gold_coin.png"
                           Height="14" Width="14"
                           Margin="1,0,5,0"/>
                    <TextBox Width="50" BorderBrush="{StaticResource TextBoxBorder}"
                             FlowDirection="RightToLeft" GotKeyboardFocus="TextBox_GotKeyboardFocus" GotMouseCapture="TextBox_GotMouseCapture">
                        <TextBox.Text>
                            <Binding Path="BuyPrice.Silver" UpdateSourceTrigger="PropertyChanged" />
                        </TextBox.Text>
                    </TextBox>
                    <Image Source="../../Resources/silver_coin.png"
                           Height="14" Width="14"
                           Margin="1,0,5,0"/>
                    <TextBox Width="50" BorderBrush="{StaticResource TextBoxBorder}"
                             FlowDirection="RightToLeft" GotKeyboardFocus="TextBox_GotKeyboardFocus" GotMouseCapture="TextBox_GotMouseCapture">
                        <TextBox.Text>
                            <Binding Path="BuyPrice.Copper" UpdateSourceTrigger="PropertyChanged" />
                        </TextBox.Text>
                    </TextBox>
                    <Image Source="../../Resources/copper_coin.png"
                           Height="14" Width="14"
                           Margin="1,0,0,0"/>
                </StackPanel>
            </StackPanel>

            <!--Sell Price-->
            <StackPanel Grid.Row="1"
                        Orientation="Vertical"
                        Margin="5">
                <core:OutlinedTextBlock Text="Sell Price" FontSize="14" ToolTipService.ShowDuration="30000">
                    <core:OutlinedTextBlock.ToolTip>
                        <ToolTip>
                            <StackPanel Orientation="Horizontal">
                                <core:OutlinedTextBlock Text="Break Even At:" FontSize="12"/>
                                <StackPanel Orientation="Horizontal" Margin="5,0,0,0" VerticalAlignment="Bottom">
                                    <core:OutlinedTextBlock Text="{Binding BreakEvenSellPrice.Gold}" />
                                    <Image Source="../../Resources/gold_coin.png"
                                           Height="11" Width="11"
                                           Margin="1,0,5,0"/>
                                    <core:OutlinedTextBlock Text="{Binding BreakEvenSellPrice.Silver}"/>
                                    <Image Source="../../Resources/silver_coin.png"
                                           Height="11" Width="11"
                                           Margin="1,0,5,0"/>
                                    <core:OutlinedTextBlock Text="{Binding BreakEvenSellPrice.Copper}"/>
                                    <Image Source="../../Resources/copper_coin.png"
                                           Height="11" Width="11"
                                           Margin="1,0,0,0"/>
                                </StackPanel>
                            </StackPanel>
                        </ToolTip>
                    </core:OutlinedTextBlock.ToolTip>
                    <core:OutlinedTextBlock.Style>
                        <Style TargetType="{x:Type core:OutlinedTextBlock}" BasedOn="{StaticResource {x:Type core:OutlinedTextBlock}}">
                            <Setter Property="Effect">
                                <Setter.Value>
                                    <DropShadowEffect ShadowDepth="0"
                                                  Color="Gold"
                                                  Opacity="0"
                                                  BlurRadius="15"/>
                                </Setter.Value>
                            </Setter>
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Trigger.EnterActions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation To="0.25"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:00.1"/>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.EnterActions>
                                    <Trigger.ExitActions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation To="0"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:0.1"/>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.ExitActions>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </core:OutlinedTextBlock.Style>
                </core:OutlinedTextBlock>
                <StackPanel Orientation="Horizontal" Margin="0,5,0,0">
                    <TextBox Width="50" BorderBrush="{StaticResource TextBoxBorder}"
                             FlowDirection="RightToLeft" GotKeyboardFocus="TextBox_GotKeyboardFocus" GotMouseCapture="TextBox_GotMouseCapture">
                        <TextBox.Text>
                            <Binding Path="SellPrice.Gold" UpdateSourceTrigger="PropertyChanged" />
                        </TextBox.Text>
                    </TextBox>
                    <Image Source="../../Resources/gold_coin.png"
                           Height="14" Width="14"
                           Margin="1,0,5,0"/>
                    <TextBox Width="50" BorderBrush="{StaticResource TextBoxBorder}"
                             FlowDirection="RightToLeft" GotKeyboardFocus="TextBox_GotKeyboardFocus" GotMouseCapture="TextBox_GotMouseCapture">
                        <TextBox.Text>
                            <Binding Path="SellPrice.Silver" UpdateSourceTrigger="PropertyChanged" />
                        </TextBox.Text>
                    </TextBox>
                    <Image Source="../../Resources/silver_coin.png"
                           Height="14" Width="14"
                           Margin="1,0,5,0"/>
                    <TextBox Width="50" BorderBrush="{StaticResource TextBoxBorder}"
                             FlowDirection="RightToLeft" GotKeyboardFocus="TextBox_GotKeyboardFocus" GotMouseCapture="TextBox_GotMouseCapture">
                        <TextBox.Text>
                            <Binding Path="SellPrice.Copper" UpdateSourceTrigger="PropertyChanged" />
                        </TextBox.Text>
                    </TextBox>
                    <Image Source="../../Resources/copper_coin.png"
                           Height="14" Width="14"
                           Margin="1,0,0,0"/>
                </StackPanel>
            </StackPanel>

            <!--Quantity-->
            <StackPanel Grid.Row="2"
                        Orientation="Horizontal"
                        Margin="5">
                <StackPanel Orientation="Vertical">
                    <core:OutlinedTextBlock Text="Quantity" FontSize="14"/>
                    <TextBox Margin="0,5,0,0" BorderBrush="{StaticResource TextBoxBorder}" Width="50" HorizontalAlignment="Left" 
                             FlowDirection="RightToLeft" GotKeyboardFocus="TextBox_GotKeyboardFocus" GotMouseCapture="TextBox_GotMouseCapture">
                        <TextBox.Text>
                            <Binding Path="Quantity" UpdateSourceTrigger="PropertyChanged" />
                        </TextBox.Text>
                    </TextBox>
                </StackPanel>
                <Button Margin="85,0,0,0" Width="50" VerticalAlignment="Bottom" HorizontalAlignment="Right"
                        Command="{Binding ResetCommand}">
                    <TextBlock Text="Reset" />
                </Button>
            </StackPanel>

            <!--Profit-->
            <StackPanel Grid.Row="3"
                        Orientation="Horizontal"
                        Margin="5"
                        ToolTipService.ShowDuration="30000">

                <core:OutlinedTextBlock Text="Profit:" FontSize="15"/>
                <StackPanel Orientation="Horizontal" Margin="5,0,0,0" VerticalAlignment="Bottom">
                    <core:OutlinedTextBlock Text="-" FontSize="14" Visibility="{Binding Profit.IsNegative, Converter={StaticResource BoolToVisibility}}" />
                    <core:OutlinedTextBlock Text="{Binding Profit.Gold}" FontSize="14" />
                    <Image Source="../../Resources/gold_coin.png"
                           Height="14" Width="14"
                           Margin="1,0,5,0"/>
                    <core:OutlinedTextBlock Text="{Binding Profit.Silver}" FontSize="14"/>
                    <Image Source="../../Resources/silver_coin.png"
                           Height="14" Width="14"
                           Margin="1,0,5,0"/>
                    <core:OutlinedTextBlock Text="{Binding Profit.Copper}" FontSize="14"/>
                    <Image Source="../../Resources/copper_coin.png"
                           Height="14" Width="14"/>
                </StackPanel>
                <StackPanel.ToolTip>
                    <ToolTip >
                        <StackPanel Orientation="Vertical">
                            <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
                                <core:OutlinedTextBlock Text="Revenue:" FontSize="12"/>
                                <StackPanel Orientation="Horizontal" Margin="5,0,0,0" VerticalAlignment="Bottom">
                                    <core:OutlinedTextBlock Text="{Binding Revenue.Gold}" />
                                    <Image Source="../../Resources/gold_coin.png"
                                           Height="11" Width="11"
                                           Margin="1,0,5,0"/>
                                    <core:OutlinedTextBlock Text="{Binding Revenue.Silver}"/>
                                    <Image Source="../../Resources/silver_coin.png"
                                           Height="11" Width="11"
                                           Margin="1,0,5,0"/>
                                    <core:OutlinedTextBlock Text="{Binding Revenue.Copper}"/>
                                    <Image Source="../../Resources/copper_coin.png"
                                           Height="11" Width="11"
                                           Margin="1,0,0,0"/>
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
                                <core:OutlinedTextBlock Text="Cost:" FontSize="12"/>
                                <StackPanel Orientation="Horizontal" Margin="5,0,0,0" VerticalAlignment="Bottom">
                                    <core:OutlinedTextBlock Text="{Binding Cost.Gold}" />
                                    <Image Source="../../Resources/gold_coin.png"
                                           Height="11" Width="11"
                                           Margin="1,0,5,0"/>
                                    <core:OutlinedTextBlock Text="{Binding Cost.Silver}"/>
                                    <Image Source="../../Resources/silver_coin.png"
                                           Height="11" Width="11"
                                           Margin="1,0,5,0"/>
                                    <core:OutlinedTextBlock Text="{Binding Cost.Copper}"/>
                                    <Image Source="../../Resources/copper_coin.png"
                                           Height="11" Width="11"
                                           Margin="1,0,0,0"/>
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
                                <core:OutlinedTextBlock Text="Listing Fee:" FontSize="12"/>
                                <StackPanel Orientation="Horizontal" Margin="5,0,0,0" VerticalAlignment="Bottom">
                                    <core:OutlinedTextBlock Text="{Binding ListingFee.Gold}" />
                                    <Image Source="../../Resources/gold_coin.png"
                                        Height="11" Width="11"
                                        Margin="1,0,5,0"/>
                                    <core:OutlinedTextBlock Text="{Binding ListingFee.Silver}"/>
                                    <Image Source="../../Resources/silver_coin.png"
                                        Height="11" Width="11"
                                        Margin="1,0,5,0"/>
                                    <core:OutlinedTextBlock Text="{Binding ListingFee.Copper}"/>
                                    <Image Source="../../Resources/copper_coin.png"
                                        Height="11" Width="11"
                                        Margin="1,0,0,0"/>
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <core:OutlinedTextBlock Text="Sale Fee:" FontSize="12"/>
                                <StackPanel Orientation="Horizontal" Margin="5,0,0,0" VerticalAlignment="Bottom">
                                    <core:OutlinedTextBlock Text="{Binding SaleFee.Gold}" />
                                    <Image Source="../../Resources/gold_coin.png"
                                        Height="11" Width="11"
                                        Margin="1,0,5,0"/>
                                    <core:OutlinedTextBlock Text="{Binding SaleFee.Silver}"/>
                                    <Image Source="../../Resources/silver_coin.png"
                                        Height="11" Width="11"
                                        Margin="1,0,5,0"/>
                                    <core:OutlinedTextBlock Text="{Binding SaleFee.Copper}"/>
                                    <Image Source="../../Resources/copper_coin.png"
                                        Height="11" Width="11"
                                        Margin="1,0,0,0"/>
                                </StackPanel>
                            </StackPanel>
                        </StackPanel>
                    </ToolTip>
                </StackPanel.ToolTip>
                <StackPanel.Style>
                    <Style TargetType="{x:Type StackPanel}">
                        <Setter Property="Effect">
                            <Setter.Value>
                                <DropShadowEffect ShadowDepth="0"
                                                  Color="Gold"
                                                  Opacity="0"
                                                  BlurRadius="15"/>
                            </Setter.Value>
                        </Setter>
                        <Style.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Trigger.EnterActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation To="0.25"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:00.1"/>
                                        </Storyboard>
                                    </BeginStoryboard>
                                </Trigger.EnterActions>
                                <Trigger.ExitActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation To="0"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:0.1"/>
                                        </Storyboard>
                                    </BeginStoryboard>
                                </Trigger.ExitActions>
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </StackPanel.Style>
            </StackPanel>

        </Grid>
    </Grid>
</src:OverlayWindow>
